import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * 服务员类
 * @author liaosh
 * @date 2022-10-21 15:51
 */
public class Waiter {
    /**
     * 存放多条命令的集合
     */
    private List<Command> orders = new ArrayList<>();

    /**
     * 添加订单
     * @param command
     */
    public void setOrder(Command command) {
        if (command instanceof BakeChickenWingCommand) {
//            System.err.println("服务员：鸡翅已售罄，请点其他菜品");
            System.out.println("服务员：鸡翅已售罄，请点其他菜品");
            return;
        } else if (command instanceof BakeMuttonCommand) {
            System.out.println("日志：增加订单：烤羊肉串，时间：" + LocalDateTime.now());
        }
        orders.add(command);
    }

    /**
     * 取消订单
     * @param command
     */
    public void cancelOrder(Command command) {
        orders.remove(command);
        System.out.println("日志：取消订单，时间：" + LocalDateTime.now());
    }

    /**
     * 通知执行命令
     */
    public void notifyExecute() {
        for (Command order : orders) {
            order.executeCommand();
        }
    }
}
